package org.zcl.拒绝策略;

/**
 * @PROJECT_NAME:
 * @DESCRIPTION:
 * @USER: ZhuChengLin
 * @DATE: 2021/11/22 15:06
 */
/**
 * 任务类
 * @author Hexiangjun
 * @version 2019-02-25 10:17
 * */
public class Task implements Runnable{

    private String taskName;

    public Task(String taskName){
        this.taskName = taskName;
    }

    @Override
    public void run() {
        System.out.println("任务" + this.taskName + "正在运行");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("任务" + this.taskName + "已经完成。当前活跃线程数：" + ThreadPool.threadPool.getActiveCount()
                + "，已完成任务数：" + ThreadPool.threadPool.getCompletedTaskCount()
                + "，阻塞队列中的任务数：" + ThreadPool.threadPool.getQueue().size());
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }
}
